<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="string" uri="http://jakarta.apache.org/taglibs/string-1.1" %>
<%@ taglib uri="/WEB-INF/tlds/pagination.tld" prefix="pagination" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Dayve web</title>
    <link href="/common/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
        // 페이지 이동을 처리한다.
        function goListPage(page) {
            var TheForm = document.frm;
            TheForm.currentPage.value = page;
            TheForm.nextTarget.value = 'photoBoardList';
            TheForm.action = './photoBoardList.do';
            TheForm.submit();
        }

        // 검색어로 리스트를 출력한다.
        function jsSearchList() {
            var TheForm = document.frm;
            TheForm.title.value = TheForm.search_title.value;
            TheForm.writer_id.value = TheForm.search_writer.value;
            TheForm.writer_nick_name.value = TheForm.search_nickName.value;
            TheForm.content.value = TheForm.search_content.value;
            TheForm.nextTarget.value = 'photoBoardList';
            TheForm.action = './photoBoardList.do';
            TheForm.submit();
        }

        // 글쓰기 페이지로 이동 : 세션이 존재할 때만 가능
        function jsWriteBoard() {
            var TheForm = document.frm;
            TheForm.nextTarget.value = 'photoBoardWrite';
            TheForm.action = './photoBoardWrite.do';
            TheForm.submit();
        }

        // 게시물 보기 페이지로 이동
        function jsContentView() {
            var TheForm = document.frm;
            TheForm.nextTarget.value = 'photoBoardContent';
            TheForm.action = './photoBoardContent.do';
            TheForm.submit();
        }

        // Community Board List 페이지로 이동한다.
        function jsCommunityBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "communityBoardList";	// page name
            TheForm.action = "./communityBoardList.do";
            TheForm.submit();
        }

        // Photo Board List 페이지로 이동한다.
        function jsPhotoBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "photoBoardList";	// page name
            TheForm.action = "./photoBoardList.do";
            TheForm.submit();
        }

        // Notice Board List 페이지로 이동한다.
        function jsNoticeBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "noticeBoardList";	// page name
            TheForm.action = "./noticeBoardList.do";
            TheForm.submit();
        }

        // Contact Us 페이지로 이동한다.
        function jsContactUs() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "contactus";	// page name
            TheForm.action = "./contactus.do";
            TheForm.submit();
        }

        // FAQ 페이지로 이동한다.
        function jsFAQ() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "faq";	// page name
            TheForm.action = "./faq.do";
            TheForm.submit();
        }

        function jsAlert(){
//            alert('내부 문제로 수정 작업 중 입니다. 이용에 불편을 드려 죄송합니다.');
            alert('<spring:message code="photoBoardList.jsAlert" />');
        }

        function jsBoardContent(boardno){
            var TheForm = document.frm;
            TheForm.boardno.value = boardno;
            TheForm.token.value = boardno;
            TheForm.nextTarget.value = 'photoBoardContent';
            TheForm.action = './photoBoardContent.do';
            TheForm.submit();
        }

    </script>
</head>


<body>
<div id="wrapper">
    <!------------------------------ top 시작-------------------------------------->
    <%@include file="header.jsp" %>
    <!------------------------------ top 끝-------------------------------------->
    <div class="sub_content">
        <form name="frm" method="POST">
            <input type="hidden" name="photo_board_no" value="">
            <input type="hidden" name="title" value="">
            <input type="hidden" name="writer_id" value="">
            <input type="hidden" name="writer_nick_name" value="">
            <input type="hidden" name="content" value="">
            <input type="hidden" name="nextTarget" value="">
            <input type="hidden" name="currentPage" value="${currentPage}">

            <input type="hidden" name="boardno" value="">
            <input type="hidden" name="page" value="${currentPage}">
            <input type="hidden" name="token" value="">

            <img src="/images/intro/sub_title04.gif" />


            <table class="notice_tb">
                <tr><td width="20%"></td><td width="20%"></td><td width="20%"></td><td width="20%"></td><td width="20%"></td></tr>
                <tr>
                    <c:set var="totalCount" value="${totalRow}"/>
                    <c:set var="countFlag" value="0"/>
                    <c:forEach items="${boardList}" var="boardList" varStatus="serviceStatus" begin="0" end="9"
                               step="1">

                    <td width="20%">
                        <table class="notice_tb">
                            <tr>
                                <c:if test="${boardList.add_thumbnail_yn == 'Y'}">
                                    <td colspan="2">
                                        <a href="javascript:jsBoardContent(${boardList.photo_board_no})">
                                            <img src="/upload/thumb/${boardList.add_thumbnail_file_name}"  width="180" height="180" class="gallery_pic" /></a>
                                    </td>
                                </c:if>
                                <c:if test="${boardList.add_thumbnail_yn == 'N'}">
                                    <td colspan="2">
                                        <a href="javascript:jsBoardContent(${boardList.photo_board_no})">
                                            <img src="/upload/thumb/empty.jpg" width="180" height="180" class="gallery_pic" /></a>
                                    </td>
                                </c:if>
                            </tr>
                            <tr>
                                <td colspan="2" class="gallery_title"><a href="javascript:jsBoardContent(${boardList.photo_board_no})">
                                        ${boardList.title}
                                    <c:if test="${boardList.reply_count > 0}">
                                        <font size="1">[${boardList.reply_count}]</font>
                                    </c:if></a></td>
                            </tr>
                            <tr>
                                <td width="100" class="gallery_id">${boardList.writer_id}</td>
                                    <%--<td width="152" class="gallery_date">${boardList.modify_date}</td>--%>
                                <td width="152" class="gallery_date">${boardList.date_part_year}<spring:message code="photoBoardList.year" />${boardList.date_part_month}<spring:message code="photoBoardList.month" />${boardList.date_part_day}<spring:message code="photoBoardList.day" /><br>${boardList.date_part_hour}<spring:message code="photoBoardList.hour" />${boardList.date_part_minute}<spring:message code="photoBoardList.min" /></td>

                            </tr>
                            <tr>
                                    <%--<td class="gallery_hit">조회 ${boardList.hitcount}</td>--%>
                                <td class="gallery_hit"><spring:message code="photoBoardList.hitcount" /> ${boardList.hitcount}</td>
                                    <%--<td class="gallery_like">추천 ${boardList.vote}</td>--%>
                                <td class="gallery_like"><spring:message code="photoBoardList.vote" /> ${boardList.vote}</td>
                            </tr>
                        </table>
                    </td>
                    <c:if test="${(serviceStatus.index+1) % 5 == 0}"></tr></c:if>
                </c:forEach>

                <%--
                페이지가 마지막일 시 게시글 숫자가 5 보다 적으면 남은 수만큼 빈 td 를 생성한다.
                --%>
                <c:if test="${emptyBoard < 5}">
                    <td colspan="${5 - emptyBoard}">
                    </td>
                </c:if>

            </table>

            <!---------------------------------------- 버튼 -------------------------------------->

            <!-- HttpSession 이 존재하지 않을 경우 글쓰기 버튼 팝업 안됨-->
            <% if(null == s.getAttribute("userId")){  %>

            <%
            }else{
            %>

            <!-- HttpSession 이 존재할 경우 글쓰기 버튼 팝업 -->
            <div class="btn_right">
                <a href="javascript:jsWriteBoard()"><img src="/images/intro/btn_write.gif" /></a>
            </div>

            <% } %>



            <div class="btn_left">
                <a href="javascript:jsPhotoBoardList()"><img src="/images/intro/btn_list.gif" /></a>
            </div>
            <!--------------------------------------- 버튼 끝 --------------------------------------->
            <div class="content_center">
                <pagination:paging>
                    <pagination:function>goListPage</pagination:function> <!-- 자바스크립트 함수 -->
                    <pagination:currentPage>${currentPage}</pagination:currentPage> <!-- 현재페이지 -->
                    <pagination:totalRows>${totalRow}</pagination:totalRows> <!-- 전체글수 -->
                    <pagination:pageSize>${pageSize}</pagination:pageSize> <!-- 페이지당 조회건수 -->
                </pagination:paging>
            </div>
            <!---------------------------------------- 검색 -------------------------------------->
            <table class="search_tb">
                <tr>
                    <td >&nbsp;</td>
                    <td width="16%" class="search_text"><spring:message code="photoBoardList.searchTitle" /></td>
                    <td width="16%" class="search_text"><spring:message code="photoBoardList.searchWriter" /></td>
                    <td width="16%" class="search_text"><spring:message code="photoBoardList.searchNickname" /></td>
                    <td width="16%" class="search_text"><spring:message code="photoBoardList.searchContent" /></td>
                    <td width="22%" class="search_text">&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="text" name="search_title" id="search_title" class="notice_input" value="${param.search_title}" /></td>
                    <td><input type="text" name="search_writer" id="search_writer" class="notice_input" value="${param.search_writer}" /></td>
                    <td><input type="text" name="search_nickName" id="search_nickName" class="notice_input" value="${param.search_nickName}" /></td>
                    <td><input type="text" name="search_content" id="search_content" class="notice_input" value="${param.search_content}" /></td>
                    <td><a href="javascript:jsSearchList()"><img src="/images/intro/btn_search.gif"  /></a></td>
                </tr>
            </table>
        </form>
    </div>

    <!------------------------------ 하위메뉴 시작-------------------------------------->
    <%@include file="footer.jsp" %>
    <!------------------------------ 하위메뉴 끝-------------------------------------->
</div>
</body>
</html>